<template>
  <Teleport to="body">
    <div class="dialog" v-show="show">
      <div class="dialog-box">
        <div class="dialog-header">{{ title }}</div>
        <div class="dialog-content">
          <slot></slot>
        </div>
        <div class="dialog-header">
          <button @click="confirm">确定</button>
          <button @click="cancel">取消</button>
        </div>
      </div>
    </div>
  </Teleport>
</template>

<script setup>
let props = defineProps(['show', 'title'])
let emits = defineEmits(['confirm', 'cancel'])

let confirm = () => {
  emits('confirm')
}
let cancel = () => {
  emits('cancel')
}
</script>

<style>
body,
html {
  height: 100%;
  width: 100%;
}
.dialog {
  height: 100%;
  width: 100%;
  background-color: rgba(52, 50, 50, 0.3);
  position: absolute;
  left: 0;
  top: 0;
}
.dialog-box {
  position: absolute;
  width: 400px;
  height: 400px;
  display: flex;
  left: 50%;
  top: 50%;
  border: 1px solid red;
  transform: translate(-50%, -50%);
  background-color: white;
  flex-direction: column;
  color: black;
  z-index: 9999;
}

.dialog-content {
  flex: 1;
}
.dialog-header {
  height: 40px;
}
.dialog-footer {
  height: 40px;
}
</style>
